package cn.suiwei.consumer.controller;

import cn.suiwei.service.AnnotateDemoService;
import cn.suiwei.service.TimeService;
import com.alibaba.dubbo.config.annotation.Reference;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * @author suiwei
 * @date 2023-02-23 14:06
 */
@RestController
public class TestController {
    @Reference
    //@DubboReference，高版本的dubbo使用
    private AnnotateDemoService animnotateDemoService;
    @Resource
    private TimeService timeService;
    @GetMapping("/")
    public LocalDateTime getTime(){
        return timeService.getTime();
    }
    @HystrixCommand(fallbackMethod = "fallback")
    @GetMapping("/demo")
    public String getAnnotateDemo(){
        return  animnotateDemoService.getAnnotateDemo();
    }
    public String fallback(){
        return  "调用了fallback";
    }
}

